<template>
  <div class="basic-form-view" v-dialogDrag>
    <el-dialog
      custom-class="small-padding-dialog el-common-dialog"
      :close-on-click-modal="false"
      title="信息查看"
      :visible.sync="dialogVisible"
      width="70%"
      @close="handleClosed"
    >
      <userInfo />
    </el-dialog>
  </div>
</template>

<script>
import { hotelBaseInfoTitle, hotelBookInfoTitle, receiveInfoList } from './config'
import commonForm from '../components/commonForm.vue'
import ViewInfo from './ViewInfo.vue'
import { putHotelBook } from '@/views/yq-personnel/api/check'
import userInfo from "@/components/business/user-details/components/userInfo.vue";
import moment from 'moment'

export default {
  name: "previewReceiv",
  components: {
    ViewInfo,
    commonForm,
    userInfo,
  },
  data() {
    return {
      //弹窗类型，默认新增
      type: "preview",
      //弹窗开关
      dialogVisible: false,
      HotelBase: [],
      hotelBaseInfoTitle,
      hotelBookInfoTitle,
      receiveInfoList,
      tableData: [],
      hotelName: '',
    }
  },
  computed: {
    // 判断是否只读
    isReadonly() {
      return ["preview"].includes(this.type);
    },
    isQualifieds() {
      return []
    }
  },
  methods: {
    //开启弹窗,
    async show({ type, data }) {
      this.type = type;
      this.dialogVisible = true;
      this.hotelName = data.hotelName
      sessionStorage.setItem("hotelName", data.hotelName);
    },

    // 弹窗关闭还原
    handleClosed() {
      this.uploadFileList = [];
      let _formData = JSON.parse(JSON.stringify(this.formData));
      let _approvalForm = JSON.parse(JSON.stringify(this.approvalForm));
      for (let i in _formData) {
        _formData[i] = "";
      }
      for (let i in _approvalForm) {
        _approvalForm[i] = "";
      }
      this.formData = _formData;
      this.approvalForm = _approvalForm;
      this.approvalList = [];
      this.$refs.dialogForm.resetFields();
    },

    submit() {
      //moment(formData.receiveTime).format('YYYY-MM-DD hh:mm:ss')
      const formData = this.$refs.receiveInfo.formData;
      const params = { ...formData, receiveTime: moment(formData.receiveTime).format('YYYY-MM-DD hh:mm:ss') }
      putHotelBook(params).then(res => {
        if (res) {
          this.dialogVisible = false;
        }
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.basic-form-view {
  /deep/ .el-date-editor--datetime {
    width: 100%;
  }
  .album {
    .el-col {
      margin-bottom: 20px;
    }
    .img {
      width: 100%;
      height: 200px;
    }
  }

  .btn-submit {
    text-align: center;
    margin-top: 20px;
  }

  /deep/ .el-dialog__body {
    padding-top: 0;
  }
}
</style>
